#ifndef SPRING_H
#define SPRING_H

#include "Spring.h"

/// @file Spring.h
/// @brief unit spring object
/// @author Perseedoss Rajiv
/// @version 1.0
/// @date 29.03.11
/// Revision History :
/// Initial Version 29.03.11
/// @class Spring
/// @brief a spring object connecting 2 particles

class Particle;

/// @enum SpringType Type Of Spring
enum SpringType
{
    STRUCTURAL_SPRING = 0,  ///< structural spring
    SHEAR_SPRING = 1,       ///< shear spring
    FLEX_SPRING = 2         ///< flex spring
};

class Spring
{
public:
    /// @brief ctor
    Spring();

    /// @brief ctor
    /// @param[in] _rootNode the root node of the spring
    /// @param[in] _endNode the end particle of the spring
    /// @param[in] _restLength the rest length of the spring
    /// @param[in] _springType the type of spring
    Spring
        (
            Particle* _rootNode,
            Particle* _endNode,
            const float _restLength,
            const SpringType _springType
        );

    /// @brief return the root node of the spring
    inline Particle* getRootNode() const { return m_rootNode; }

    /// @brief return the end node of the spring
    inline Particle* getEndNode() const { return m_endNode; }

    /// @brief return the rest length of the spring
    inline float getRestLength() const { return m_restLength; }

    /// @brief return the type of the spring
    inline SpringType getSpringType() const { return m_springType; }

    /// @brief return whether the spring is valid
    inline bool isValid() const { return m_restLength != -1; }

private:
    /// @brief the root node of the spring
    Particle* m_rootNode;

    /// @brief the end node of the spring
    Particle* m_endNode;

    /// @brief the rest length of the spring
    float m_restLength;

    /// @brief the type of the spring
    SpringType m_springType;
};

#endif // SPRING_H
